<?php

use App\Admin\Extensions\Area;
use Dcat\Admin\Admin;
use Dcat\Admin\Layout\Navbar;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */
Admin::baseCss(['css/theme.css'], true);

// 在bootstrap.php中加入
Dcat\Admin\Color::extend('mytheme', [
    'primary' => '#1890ff',
    'primary-darker' => '#1890ff',
    'link' => '#1890ff',
]);

// 注册area联动前端组件别名
Admin::asset()->alias('@area', [
    'js' => ['/vendor/area/distpicker.js']
]);
\Dcat\Admin\Form::extend('area', Area::class);
\Dcat\Admin\Form::extend('sku', \App\Admin\Extensions\Sku::class);

Admin::navbar(function (Navbar $navbar) {
    // 切换主题
//    $navbar->right(view('admin.switch-theme', [
//        'map' => [
//            'indigo' => Dcat\Admin\Admin::color()->indigo(),
//            'blue' => '#5686d4',
//            'blue-dark' => '#5686d4',
//        ],
//    ]));
    $method = config('admin.layout.horizontal_menu') ? 'left' : 'right';

//    $navbar->$method(
//        <<<HTML
//<ul class="nav navbar-nav">
//    <li class="nav-item">
//        &nbsp;
//        <a style="cursor: pointer" onclick="window.open('https://github.com/jqhph/dcat-admin-demo')">
//            <i class="feather icon-github" style="font-size: 1.5rem"></i> DEMO源码下载
//        </a>
//        &nbsp; &nbsp;
//    </li>
//</ul>
//HTML
//
//    );

    // ajax请求不执行
    if (!Dcat\Admin\Support\Helper::isAjaxRequest()) {
        $navbar->$method(App\Admin\Actions\AdminSetting::make()->render());
    }

    // 下拉菜单
    //$navbar->right(view('admin.navbar-2'));

    // 搜索框
    $navbar->right(
        <<<HTML
HTML
    );

    // 下拉面板
//    $navbar->right(view('admin.navbar-1'));
});
config([
    'app.locale' => admin_setting('lang'),
    "admin.name" => admin_setting('web-name'),
    "admin.logo" => admin_setting('logo'),
    "admin.logo-mini" => admin_setting('logo-mini'),
    "admin.layout.sidebar_style" => json_decode(admin_setting('layout'))->sidebar_style,
    "admin.layout.color" => json_decode(admin_setting('layout'))->color,
    "admin.layout.body_class" => json_decode(admin_setting('layout'))->body_class,
    "admin.helpers.enable" => json_decode(admin_setting('helpers'))->enable
]);
